package com.taptech.doufu.ui.view.colorful.setter;

import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.view.View;
import android.widget.ImageView;

/**
 * View的背景Drawabler Setter
 * 
 */
public final class ViewImagResourceSetter extends ViewSetter {

	public ViewImagResourceSetter(View targetView, int resId) {
		super(targetView, resId);
	}


	public ViewImagResourceSetter(int viewId, int resId) {
		super(viewId, resId);
	}

	@SuppressWarnings("deprecation")
	@Override
	public void setValue(Theme newTheme, int themeId) {
		if ( mView == null ) {
			return  ;
		}
		TypedArray a = newTheme.obtainStyledAttributes(themeId,
				new int[] { mAttrResId });
		int attributeResourceId = a.getResourceId(0, 0);
//		Drawable drawable = mView.getResources().getDrawable(
//				attributeResourceId);
		a.recycle();
		((ImageView)mView).setImageResource(attributeResourceId);
	}

}
